package com.chaber.containers.presenters;

import javafx.event.ActionEvent;
import javafx.event.EventHandler;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;

import com.chaber.containers.common.MessageEvent;
import com.chaber.containers.views.MessageView;

public class MessagePresenter extends AbstractPresenter implements ApplicationListener<MessageEvent> {

	@Autowired
	private MessageView messageView;
	
	@Override
	public void onApplicationEvent(MessageEvent event) {
		this.messageView.getMessage().setText(event.getMessage());
		this.messageView.show();
	}

	@Override
	public void bindViewActions() {
		this.messageView.getConfirmButton().setOnAction(new EventHandler<ActionEvent>() {
			@Override
			public void handle(ActionEvent arg0) {
				messageView.hide();
			}
		});
	}
	
}
